#!/bin/bash


hadoop_home=/naver/pos/hadoop/hadoop-0.18.3/
pos_home=/home1/irteam/jjlee/workspace/dev-mpl-estimate
hdfs_cpcest_bidamt=/user/kwd_ad/analysis/cpcest/bidamt
keyword_id_dict=/user/kwd_ad/analysis/cpcest/bidamt/dict/reqid_30000.txt

function run_daily()
{
	stat_dt=`date +%C%y%m%d --date ${1}`

	echo "hadoop_home = ${hadoop_home}"
	echo "pos_home = ${pos_home}"
	echo "stat_dt = ${stat_dt}"

	${hadoop_home}/bin/hadoop dfs -rmr  ${hdfs_cpcest_bidamt}/day/${stat_dt}
	${hadoop_home}/bin/hadoop jar ${hadoop_home}/lib/marie-0_1.jar com.nbp.searchad.marie.runner.Marie -jar ${pos_home}/searchad_cpcest_bidamt.jar -input /user/kwd_ad/logs/impmedia/${stat_dt}/ -input /user/kwd_ad/logs/clknarev/${stat_dt} -input /user/kwd_ad/logs/impna/${stat_dt} -input /user/kwd_ad/logs/clkmediarev/${stat_dt} -output ${hdfs_cpcest_bidamt}/day/${stat_dt} -work BidAmtDay  -dfsCache ${keyword_id_dict}
	chk cpcest_bidamt.mapreduce
	${hadoop_home}/bin/hadoop dfs -getmerge ${hdfs_cpcest_bidamt}/day/${stat_dt} /tmp/daymerge.$stat_dt
	chk cpcest_bidamt.getmerge
	${hadoop_home}/bin/hadoop dfs -rm ${hdfs_cpcest_bidamt}/day/${stat_dt}/*
	${hadoop_home}/bin/hadoop dfs -put /tmp/daymerge.$stat_dt ${hdfs_cpcest_bidamt}/day/${stat_dt}
	chk cpcest_bidamt.put.$stat_dt
}

run_daily 2013-07-12
